<?php
/**
 * User: jintao
 */
class erpapi_shop_request_finance extends erpapi_shop_request_abstract
{
    public function sync_bills_book_get($account_id,$start_time,$end_time,$journal_types = '',$page_no = 1,$page_size = 40){}

    public function bills_book_get($account_id,$start_time,$end_time,$journal_types = '',$page_no = 1,$page_size = 40){}

    public function bills_book_get_callback($response, $callback_params){}

    private function get_fee_item($outer_id){}

    public function bills_get($start_time,$end_time,$page_no=1,$page_size=40,$time_type=''){}

    public function trade_search($shop_id,$shop_name,$start_time,$end_time,$page=1,$limit=100){}

    public function trade_taskresult_get($shop_id,$task_id){}

    public function trade_taskid_get($shop_id,$start_time,$end_time){}

    public function addPayment($payment){}

    public function updatePaymentStatus($payment){}

    public function addRefund($refund){}

    public function updateRefundStatus($refundinfo) {}

    public function getRefundMessage($refundinfo){}

    public function addRefundMemo($refundinfo){}

    public function getRefundDetail($refund_id ,$refund_phase,$tid){}

    protected function _updateRefundApplyStatusApi($status){
        return '';
    }

    protected function _updateRefundApplyStatusParam($refund, $status)
    {
        return array();
    }

    /**
     * 更新退款单状态
     */
    public function  updateRefundApplyStatus($refund,$status,$mod = 'sync')
    {
        $orderModel = app::get('ome')->model('orders');
        $orderData = $orderModel->getList('order_bn', array('order_id'=>$refund['order_id']), 0, 1);
        $order = $orderData[0];
        $api_method = $this->_updateRefundApplyStatusApi($status);
        if ($api_method == '' || $mod != 'sync') {
            return false;
        }
        $params = $this->_updateRefundApplyStatusParam($refund, $status);
        $params['tid'] = $order['order_bn'];
        $title = '店铺('.$this->__channelObj->channel['name'].')更新[交易退款状态],(订单号:'.$order['order_bn'].'退款单号:'.$refund['refund_apply_bn'].')';
        $callback = array();
        $result = $this->__caller->call($api_method, $params, $callback, $title, 10, $order['order_bn']);
        $rs = array();
        if(isset($result['msg']) && $result['msg']){
            $rs['msg'] = $result['msg'];
        }elseif(isset($result['err_msg']) && $result['err_msg']){
            $rs['msg'] = $result['err_msg'];
        }elseif(isset($result['res']) && $result['res']){
            $rs['msg'] = $result['res'];
        }
        $rs['rsp'] = $result['rsp'];
        return $rs;
    }

}
